1. Field of the Invention
The present invention relates to an information processing program and an information processing apparatus, and more particularly to an information processing program and an information processing apparatus both for calculating an output value based on a tilt of an input device capable of being tilted at any tilt angle.
2. Description of the Background Art
Patent document 1 (Japanese Laid-Open Patent Publication No. 6-190144) discloses a game apparatus capable of performing a game operation by tilting a controller. The controller (control key device) disclosed in patent document 1, having a triaxial acceleration sensor embedded therein, calculates a tilt angle of the controller by using the acceleration sensor. Furthermore, patent document 1 discloses that in a driving game played using the controller, the tilt angle of the controller is applied to a turning angle of a steering wheel of a vehicle appearing in the game.
In the above-described game apparatus capable of performing a game operation by tilting the controller, a player can tilt the controller at any tilt angle. On the other hand, an allowable range may be determined for an output value changed in accordance with the tilt angle of the controller. For example, in the case where an output value is applied to the turning angle of the steering wheel, an allowable range of the turning angle of the steering wheel may be determined. As such, while no limit is provided for a value of a tilt angle of the controller (i.e., an input value), a limit may be provided for an output value.
When a limit is set for an allowable range of an output value, it is considered to fixedly set a tilt angle, of the controller, obtained when an output value is equal to a boundary value of the range (e.g., an upper value and a lower value of the allowable range of the output value). That is, the output value is calculated so as to remain unchanged even if the controller is tilted at an angle greater than the boundary angle. However, in the case where the tilt angle is fixedly set, when the player tilts the controller within a range in which an output value remains unchanged even if the controller is tilted at an angle greater than the boundary angle, the output value never changes even though the controller is being moved. In this case, the player may feel that an operation applied to the controller does not reflect an output. Therefore, he or she may feel that an operation is not easy to perform.
Therefore, an object of an illustrative implementation is to provide a storage medium storing an information processing program and an information processing apparatus both of which are capable of improving the ease of operation using an input device capable of being tilted at any angle.
An illustrative implementation has the following features to attain the object mentioned above. The reference numerals, supplemental remarks and the like in the parentheses indicate the correspondence with the embodiment described below in order to aid in understanding the present invention and are not intended to limit, in any way, the scope of the present invention.
A first aspect is a computer-readable storage medium (optical disc 4) storing an information processing program (game program 60) to be executed by a computer (CPU 10) of an information processing apparatus (game apparatus 3) which calculates an output value within a predetermined range in accordance with a tilt angle of an input device (controller 5) capable of being tilted at any angle. Storage means (main memory) of the information processing apparatus stores boundary angle data (66, 67) representing a boundary angle corresponding to the tilt angle, of the input device, obtained when the output value is equal to a value of a boundary of the predetermined range. The information processing program causes the computer to execute a tilt calculation step (S2, S4), a first update step (S5) and an output calculation step (S6). In the tilt calculation step, the computer calculates the tilt angle of the input device by obtaining, from the input device, input data (acceleration data 62) including a value changed in accordance with the tilt angle of the input device. In the first update step, the computer updates, when the tilt angle calculated in the tilt calculation step is greater than the boundary angle represented by the boundary angle data, the boundary angle data such that the tilt angle calculated in the tilt calculation step becomes a new boundary angle. In the output calculation step, the computer calculates the output value based on a ratio of the tilt angle calculated in the tilt calculation step to the boundary angle represented by the boundary angle data.
In a second aspect, the storage means may further store a reference angle of the boundary angle. In this case, the information processing program causes the computer to further execute a second update step (S6) of updating, when the tilt angle calculated in the tilt calculation step is less than the boundary angle represented by the boundary angle data, the boundary angle data such that the boundary angle becomes the reference angle.
In a third aspect, the tilt calculation step may be repeatedly executed. In this case, the second update step includes a reduction step (S43 to S47) of repeatedly executing, each time the tilt calculation step calculates the tilt angle, a reduction process of decreasing the boundary angle within a range in which the boundary angle represented by the boundary angle data does not become less than the reference angle, until the boundary angle becomes equal to the reference angle.
In a fourth aspect, in the reduction step, the reduction process may be executed so as to decrease the boundary angle within a range in which the boundary angle represented by the boundary angle data does not become less than the tilt angle calculated in the tilt calculation step.
In a fifth aspect, the input device may include an acceleration sensor (37) for detecting an acceleration generated in the input device. In this case, the tilt calculation step includes an obtainment step (S2) and a calculation execution step (S4). In the obtainment step, the computer obtains the acceleration detected by the acceleration sensor. In the calculation execution step, the computer calculates the tilt angle of the input device by using the acceleration having been obtained.
In a sixth aspect, the tilt calculation step may further include a correction step (S3) for correcting the acceleration having been obtained. In this case, the obtainment step, the correction step and the calculation execution step are repeatedly executed. In the correction step, the computer corrects the acceleration which is currently obtained in the obtainment step so as to be close to a most recently corrected acceleration. In the calculation execution step, the computer calculates the tilt angle of the input device by using the acceleration corrected in the correction step.
In a seventh aspect, in the correction step, the computer corrects the currently obtained acceleration such that the closer a magnitude of the currently obtained acceleration is to a magnitude of a gravitational acceleration, the closer the corrected currently obtained acceleration becomes to the currently obtained acceleration before being corrected.
In an eighth aspect, the acceleration sensor may detect the acceleration along respective axes of a predetermined three-dimensional coordinate system (XYZ coordinate system) set with respect to the input device. In this case, in the obtainment step, the computer obtains the acceleration represented by a three-dimensional vector in the three-dimensional coordinate system from the acceleration sensor. In the calculation execution step, the computer converts the three-dimensional vector into a two-dimensional vector on a plane (plane P) passing through an origin of the three-dimensional coordinate system, and represents the tilt angle of the input device by the two-dimensional vector having been converted.
In a ninth aspect, in the calculation execution step, the computer may convert the three-dimensional vector into a two-dimensional vector on a plane containing one axis of the three-dimensional coordinate system.
The present invention may be provided with an information processing device having a function equivalent to that of the information processing device executing the aforementioned steps from the first to ninth aspects. Furthermore, the present invention may be provided as an output value calculation method in which the aforementioned steps from the first to ninth aspects are executed.
According to the first aspect, when the tilt angle of the input device is greater than the boundary angle, the boundary angle data is updated such that the tilt angle becomes the new boundary angle. Then, the output value is calculated based on a ratio of the tilt angle to the boundary angle represented by the boundary angle data having been updated. Therefore, an operation applied to the input device always reflects an output value, thereby avoiding a problem that the output value remains unchanged even if the tilt angle of the input device changes. That is, it becomes possible to avoid the problem that the output value remains unchanged even if the operation is applied to the input device, whereby an ease of operation using the input device can be improved.
According to the second aspect, even when a boundary angle is changed in the first update step, the boundary angle returns to the reference angle if the tilt angle decreases thereafter. Therefore, even when a user tilts the input device at an angle steeper than necessary (i.e., at an angle greater than the reference angle) for some reason, he or she does not need to tilt the input device to a extent larger than necessary thereafter, thereby making it possible to improve the ease of operation.
According to the third aspect, the boundary angle gradually returns to the reference angle in the reduction step. Note that if a tilt angle remains unchanged and an output value changes in accordance with only a boundary angle being changed, the output value unexpectedly changes even though the user does not operate the input device, and therefore the user may feel awkward. On the contrary, according to the third aspect, the boundary angle is gradually changed, thereby reducing a change amount of the output value changed in accordance with the boundary angle being changed. Thus, it becomes possible not to cause the user to feel awkward.
In a fourth aspect, the boundary angle never becomes less than the tilt angle. Thus, it becomes possible to prevent the output value from becoming a value greater than a value within the predetermined range.
In a fifth aspect, by using the acceleration sensor, the tilt angle of the input device can be easily calculated.
According to the sixth aspect, the corrected acceleration which is corrected in the corrected step changes in accordance with the acceleration obtained from the acceleration sensor. Therefore, the corrected acceleration remains constant even when the obtained acceleration subtly changes, thereby making it possible to prevent an output value from being changed due to hand shake movement.
According to the seventh aspect, when the magnitude of the acceleration which is currently obtained is close to the magnitude of the gravitational acceleration, the corrected acceleration is calculated so as to be close to the magnitude of the acceleration. Therefore, in the case where the obtained acceleration is reliable (i.e., the acceleration accurately represents the tilt angle), the corrected acceleration is to be a value close to the obtained acceleration. Thus, it becomes possible to more accurately calculate the tilt angle by using the corrected acceleration.
According to the eight and ninth aspects, the acceleration represented by the three-dimensional vector is converted into an acceleration represented by the two-dimensional vector, thereby making it possible to easily execute a calculation process of the output value.
These and other objects, features, aspects and advantages of the illustrative implementations will become more apparent from the following detailed description of the present invention when taken in conjunction with the accompanying drawings.